package SpringProject.Annotation;

import SpringProject.Domain.Person;

import java.lang.reflect.Field;

public class ExtendsUtils {
    public void parseAnnotation(Person person) throws IllegalAccessException {
        Field[] fields = person.getClass().getDeclaredFields();
        for (Field field : fields) {
            if(field.isAnnotationPresent(Extends.class)){
                field.setAccessible(true);
                Extends annotation = field.getAnnotation(Extends.class);
                String name=annotation.name();
                field.set(person,name);
            }
        }
    }

    public static void main(String[] args) throws IllegalAccessException {
       Person p=new Person();
        ExtendsUtils utils=new ExtendsUtils();
        utils.parseAnnotation(p);
        p.getUserName();
    }
}
